<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>权限菜单-列表页</title>
    <link rel="stylesheet" th:href="@{/resources/bootstrap/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/resources/plugins/bootstrap-table/bootstrap-table.min.css}">
    <link rel="stylesheet" th:href="@{/resources/awi/css/font-awesome.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/resources/awi/css/AdminLTE.min.css}">
    <link rel="stylesheet" th:href="@{/resources/awi/css/skins/all-skins.min.css}">
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="page-header">
                <h3>系统设置
                    <small>流程管理</small>
                </h3>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="box box-solid box-info">
                <div class="box-header">查询参数</div>
                <div class="box-body">
                    <form id="search-form" class="form-inline">
                        <div class="col-md-3 form-group">
                            <label>类别</label>
                            <input type="text" class="form-control params" name="category" id="category">
                        </div>
                        <div class="col-md-3">
                            <div class="btn-group">
                                <button type="button" class="btn btn-success" onclick="tableDataRefresh('#authMenu-data-table')"><i class="fa fa-search"></i>查询</button>
                                <button type="reset" class="btn btn-warning"><i class="fa fa-refresh"></i> 重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="row" id="toolbar">
        <div class="col-md-12">
            <div class="btn-group">
                <button type="button" class="btn btn-info" onclick="createNew()"><i class="fa fa-plus"></i>流程发布</button>
                <button type="button" class="btn btn-danger" onclick="batchRemove()"><i class="fa fa-remove"></i>删除</button>
                <button type="button" class="btn btn-success" onclick="tableDataRefresh('#authMenu-data-table')"><i class="fa fa-refresh"></i>刷新</button>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 table-responsive">
            <table id="processDefinition-data-table" data-url="/processSetting/getPagingProcessDefinition" class="data-table"  data-classes="table table-no-bordered"
                   data-locale="zh-CN" data-pagination="true" data-response-handler="dataTableResponseHandler"
                   data-unique-id="uid" data-id-field="id" data-side-pagination="server"
                   data-toolbar="toolbar"  	data-query-params-type="limit" data-height="730" data-striped="true" data-click-to-select="true"
                   data-query-params="dataTableQueryParams" data-method="post" data-content-type="application/x-www-form-urlencoded"
            >
                <thead>
                <tr>
                    <th data-title="申请名称" data-field="name" data-align="center" data-valign="middle" data-width="150"></th>
                    <th data-title="类别" data-field="category" data-align="center" data-valign="middle" data-width="150"></th>
                    <th data-title="流程说明" data-field="description" data-align="center" data-valign="middle" data-width="350"></th>
                    <th data-title="操作" data-field="processDefinitionId" data-align="center" data-valign="middle" data-width="100"
                        data-formatter="opFormatter"></th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
</body>
<script th:src="@{/resources/plugins/jQuery/jquery-2.2.3.min.js}"></script>
<!-- Bootstrap 3.3.6 -->
<script th:src="@{/resources/bootstrap/js/bootstrap.min.js}"></script>

<!-- Bootstrap 3.3.6 -->
<script th:src="@{/resources/plugins/bootstrap-table/bootstrap-table.min.js}"></script>
<script th:src="@{/resources/plugins/bootstrap-table/bootstrap-table-locale-all.min.js}"></script>
<script th:src="@{/resources/layer/layer.js}"></script>
<script th:src="@{/resources/plugins/plugins-init/plugins-init.js}"></script>
<script th:src="@{/resources/commons/js/prototype.js}"></script>
<script type="text/javascript">

    function createNew() {
        layer.open({
            title: '流程发布',
            type: 2,
            content: '/processSetting/toProcessDeploy',
            area: ['800px', '600px'],
            maxmin: true,
            end:function () {
                tableDataRefresh('#processDefinition-data-table')
            }
        });
    }
    function opFormatter(value, row, index) {
        var operation='<div class="btn-group">'+
            '<button type="button" class="btn btn-sm  btn-primary dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-cogs"></i>请选择操作 <span class="caret"></span>'+
            '</button> <ul class="dropdown-menu" role="menu">'+
            '<li><a href="javascript:remove(\''+row.deploymentId+'\')"><i class="fa fa-remove"></i>流程删除</a></li>'+
            '<li><a href="javascript:handlerSetting(\''+row.processDefinitionId+'\')"><i class="fa fa-cog"></i>流程设置</a></li>'+
            '</ul> </div>';
        return operation;
    }

    function handlerSetting(processDefinitionId) {
        layer.open({
            title: '办理人设置',
            type: 2,
            content: '/processSetting/to/taskHandlerSetting?processDefinitionId='+processDefinitionId,
            area: ['800px', '600px'],
            maxmin: true,
            end:function () {
                tableDataRefresh('#processDefinition-data-table')
            }
        });
    }

    function remove(deploymentId){
        $.get("/processSetting/delete?deploymentId="+deploymentId,function(data){
            $("#processDefinition-data-table").bootstrapTable('refresh');
        })
    }


</script>
</html>